//package com.asset.salesforce.dao;
//
//import org.apache.shiro.crypto.hash.Sha256Hash;
//import org.hibernate.SessionFactory;
//import org.springframework.beans.factory.InitializingBean;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.stereotype.Component;
//import org.springframework.stereotype.Repository;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import javax.sql.DataSource;
//
//@Repository
//public class BootstrapDataPopulator implements InitializingBean {
//	
//    private DataSource dataSource;
//    
//    @Autowired
//    public void setDataSource(DataSource dataSource) {
//        this.dataSource = dataSource;
//    }
//    
//    
//    
//    @Autowired
//    private UserShiroDaoImpl userShiroDaoImpl;
//    // Session factory is only injected to ensure it is initialized before this runs
//    
//    @Autowired
//    private  SessionFactory sessionFactory;
//    
//
//    public void afterPropertiesSet() throws Exception {
//        //because we're using an in-memory hsqldb for the sample app, a new one will be created each time the
//        //app starts, so insert the sample admin user at startup:
//        JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource);
//        
//        if(!((userShiroDaoImpl.findUser("user") != null && userShiroDaoImpl.findUser("user").getId().equals(1))||
//        		(userShiroDaoImpl.findUser("admin") != null && userShiroDaoImpl.findUser("admin").getId().equals(2))
//        )){
//          jdbcTemplate.execute("insert into roles values (1, 'user', 'The default role given to all users.')");
//          jdbcTemplate.execute("insert into roles values (2, 'admin', 'The administrator role only given to site admins')");
//      	  jdbcTemplate.execute("insert into roles values (3, 'employee', 'The employee role only given to site admins')");	
//          jdbcTemplate.execute("insert into roles_permissions values (2, 'user:*')");
//      	  jdbcTemplate.execute("insert into roles_permissions values (3, 'employee:*')");
//          jdbcTemplate.execute("insert into users(id,username,email,password) values (1, 'admin', 'sample@shiro.apache.org', '" + new Sha256Hash("admin").toHex() + "')");
//          jdbcTemplate.execute("insert into users(id,username,email,password) values (2, 'employee', 'employee@shiro.apache.org', '" + new Sha256Hash("employee").toHex() + "')");
//      	  jdbcTemplate.execute("insert into users_roles values (2, 3)");
//          jdbcTemplate.execute("insert into users_roles values (1, 2)");
//        }
//
////        
//
//
//    }
//}
